package com.paperlessmedical.action;

import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.paperlessmedical.bean.PageView;
import com.paperlessmedical.bean.QueryResult;
import com.paperlessmedical.entity.Clinic;
import com.paperlessmedical.entity.Doctor;
import com.paperlessmedical.entity.Patient;
import com.paperlessmedical.entity.Register;
import com.paperlessmedical.service.ClinicService;
import com.paperlessmedical.service.RegisterService;


@Controller @SuppressWarnings("serial")
public class ClinicAction extends ActionSupport{
    @Resource(name="clinicServiceImpl")
    private ClinicService clinicService;
    
	private PageView<Clinic> pageView;
	private int pageID;
	private QueryResult<Clinic> qr;
	private String name;
	private String query;
	
	
	@Override
	public String execute() throws Exception {
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		orderby.put("clinic_Id", "desc");
		pageView=new PageView<Clinic>(12,pageID);
		int firstindex= (pageView.getCurrentpage()-1)*pageView.getMaxresult();
		qr=clinicService.getScrollDate_Hql(Clinic.class, firstindex, pageView.getMaxresult(),orderby);
		pageView.setQueryResult(qr); 
//		System.out.println(pageView.getRecords().get(0).getClinic_Name());
		return INPUT;
	}

//	public String clinicList(){
//		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
//		orderby.put("clinic_Id", "desc");
//		pageView=new PageView<Clinic>(12,pageID);
//		int firstindex= (pageView.getCurrentpage()-1)*pageView.getMaxresult();
//		qr=clinicService.getScrollDate_Hql(Clinic.class, firstindex, pageView.getMaxresult(),orderby);
//		pageView.setQueryResult(qr); 
////		System.out.println(qr.getListResult().get(0).getClinic_Name());
//		return "cliniclist";
//	}

	public PageView<Clinic> getPageView() {
		return pageView;
	}

	public void setPageView(PageView<Clinic> pageView) {
		this.pageView = pageView;
	}

	public int getPageID() {
		return pageID;
	}

	public void setPageID(int pageID) {
		this.pageID = pageID;
	}

	public QueryResult<Clinic> getQr() {
		return qr;
	}

	public void setQr(QueryResult<Clinic> qr) {
		this.qr = qr;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}
	
	
}
